<template>
  <div class="voice-popup" v-if="show">
    <div class="voice-animation" @click="togglePause" :class="{'paused': isPaused}">
      <i class="bi" :class="isPaused ? 'bi-play-fill' : 'bi-volume-up'"></i>
    </div>
    <div class="voice-text">{{ isPaused ? "语音已暂停" : "正在播放语音..." }}</div>
    <div class="voice-status">{{ currentText }}</div>
    <button class="voice-close-btn" @click="close" title="关闭语音">
      <i class="bi bi-x"></i>
    </button>
  </div>
</template>

<script setup>
import { ref, watch } from 'vue'

const props = defineProps({
  show: Boolean,
  isPaused: Boolean,
  currentText: String
})

const emit = defineEmits(['toggle-pause', 'close'])

const togglePause = () => {
  emit('toggle-pause')
}

const close = () => {
  emit('close')
}
</script>

<style scoped>
.voice-popup {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background-color: white;
  border-radius: 12px;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.voice-animation {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  animation: pulse 2s infinite;
}

.voice-animation.paused {
  animation: none;
  opacity: 0.8;
}

.voice-text {
  color: var(--text-primary);
  font-weight: 500;
}

.voice-status {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
}

.voice-close-btn:hover {
  color: var(--danger-color);
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}
</style> 